package cn.sunlight.college.oss.controller;

import cn.sunlight.college.common.utils.R;
import cn.sunlight.college.oss.service.OSSService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName OSSController
 * @Description 阿里云文件管理
 * @Author liugang
 * @Date 2021/6/12 ~ 11:45 下午
 * @Version V1.0
 */
@Api(description="阿里云文件管理")
@CrossOrigin  //解决跨域
@RestController
@RequestMapping("/eduOss/fileOss")
public class OSSController {

    @Autowired
    private OSSService ossService;

    @ApiOperation(value = "文件上传")
    @PostMapping()
    public R uploadOssFile(MultipartFile file){
        //返回上传到oss的路径
        String url=ossService.uploadFileAvatar(file);
        return R.ok().message("文件上传成功").data("url",url);
    }


}
